#
# @lc app=leetcode.cn id=452 lang=python
#
# [452] 用最少数量的箭引爆气球
#

# @lc code=start
class Solution(object):
    def findMinArrowShots(self, points):
        """
        :type points: List[List[int]]
        :rtype: int
        """
        arrowshots = 1
        points.sort(key=lambda x:(x[0], x[1]))
        start = points[0][0]
        end = points[0][1]
        
        for i in range(len(points)):
            start = points[i][0]
            if start > end:
                arrowshots += 1
                end = points[i][1]
            else:
                end = min(points[i][1], end)
        return arrowshots
        
# @lc code=end

